package tw.com.msig.spring.hibernate.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tw.com.msig.spring.hibernate.dao.RoleDao;
import tw.com.msig.spring.hibernate.entity.Role;

@Service
public class RoleService {

	@Autowired
	private RoleDao RoleDao;
	
	public List<Role> getAll() {
		return RoleDao.findAll();
	}
	
	public Role insert(Role Role) {
		return RoleDao.insert(Role);
	}
	
	public Role getOne(Long id) {
		return RoleDao.findOne(id);
	}
	
	public void delete(Long id) {
		RoleDao.delete(id);
	}
	
	public void update(Role Role) {
		
		Role dbUser = getOne(Role.getId());
		dbUser.setName(Role.getName());
		RoleDao.update(dbUser);
	}
	
	
	
	
	
	
	
	
}